<admintpl file="header" />
<script type="text/javascript" src="__PUBLIC__/js/jquery.cityselect.js"></script>
</head>
<style>
    .input_edit{
        width:120px;
    }
</style>
<body>
<div class="wrap js-check-wrap">
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li class="active"><a href="{:U('company/index')}">公司列表</a></li>
            <!--<li><a href="{:U('company/addCompany')}">添加公司</a></li>-->
        </ul>

        <form class="well form-search" id="query_form" method="post" action="{:U('Admin/Company/index')}">
            <div class="control-group">
                <label class="span1 control-label" style="width: 90px;"> 已有公司 {$company_count|default=0} 家</label>
                <label class="span1 control-label" style="width: 90px;"> 已有员工 {$people_count|default=0} 人</label>
            </div>

            <div class="control-group">
                <label class="span1 control-label" style="width: 90px;">公司名称：</label>
                <div class="span4">
                    <input type="text" name="company_name" value="<?php if($company_name){echo $company_name;}?>">
                </div>
            </div>

            <div class="control-group">
                <label class="span1 control-label" style="width: 90px;"> 所在地区：</label>
                <div id="city_1">
                    <select class="prov" name="prov"></select>
                    <select class="city" name="city" id="city" disabled="disabled"></select>
                </div>
            </div>
            <input type="submit" id="queryBtn" data-action="{:U('Admin/Company/index')}" class="btn btn-primary" value="查询" />
        </form>

        <form class="js-ajax-form" action="" method="post">
            <table class="table table-hover table-bordered">
                <thead>
                <tr>
                    <!--<th>序号</th>-->
                    <th>公司名称</th>
                    <th>员工数量</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <foreach name="data" item="vo">
                    <tr>
                        <!--<td><input name="news_ids[]"  type="checkbox" value="{$carousel_figure_vo.vote_id}"></td>-->
                        <!--<td>{$vo.company_id}</td>-->
                        <td>{$vo.name}</td>
                        <td>{$vo.people_count}</td>
                        <td>{$vo.create_time|date="Y-m-d H:i:s",###}</td>
                        <td>
                            <a id="edit" href="{:U('Company/editCompany', array('company_id'=>$vo['company_id']))}" onclick="">编辑</a>
                            <a id="look" href="{:U('PeopleManagement/index', array('company_id'=>$vo['company_id']))}" onclick="">查看员工</a>
                        </td>
                    </tr>
                </foreach>
                </tbody>
            </table>
        </form>
        <div class="pagination">{$page}</div>
    </div>

</div>
<script src="__PUBLIC__/js/common.js"></script>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script>
    $(function () {
        var prov = '{$prov}';
        var city = '{$city}';
        prov = prov ? prov : '请选择';
        city = city ? city : '';
        $("#city_1").citySelect({
            url:"/public/js/city.js",
            prov: prov,
            city: city,
            nodata:"none" //当子集无数据时，隐藏select
        });

        $('input[name="query_form_btn"]').click(function(){
            $('#query_form').attr('action', $(this).attr('data-action'));
            $('#query_form').submit();
        });
    })
    function editCompanyStatus(company_id, status_id) {
        if(!confirm('确认关闭此公司？')){
            return false;
        }

        if(!company_id){
            alert('参数错误');
            return false;
        }
        var data = {company_id: company_id, status: status_id}
        $.ajax({
            url: "{:U('Company/editCompanyStatus')}",
            type: "POST",
            data: data,
            dataType: "json",
            success: function (res) {
                var ret = eval(res);
                if(ret.code == 200){
                    alert('修改成功');
                    location.reload();
                }else{
                    alert(res.msg);
                }
            },
            error: function () {
                alert('网络错误，请稍后再试');
            },
        })
    }
    function edit_admin(column_id,admin_ids,usernames){
        layer.open({
            type: 2,
            //skin: 'layui-layer-lan',
            title: '修改管理员',
            fix: false,
            shadeClose: true,
            maxmin: true,
            area: ['600px', '300px'],
            content: "<?php echo U('Admin/NewsSet/editAdmin')?>"+'&column_id='+column_id+'&admin_ids='+admin_ids+'&usernames='+usernames,
            end: function(){
                location.reload();
            }
        });
    }
    function edit_column(type,column_id){
        var edit_column;
        var column_befor;
        var column;
        var now_input_type;
        var now_edit_type;
        if(type == "column_id"){
            edit_column = $("#edit_column-"+column_id).html();
            column_befor = $("#dis_column_name").html();   //原栏目名
            column  = $("#input-column-"+column_id).val(); //现栏目名
            now_input_type = $("#input-column-" + column_id); //栏目 ID
            now_edit_type  = $("#edit_column-" + column_id);  //修改 按钮ID
        }else if(type == "weight"){
            edit_column = $("#edit_weight-"+column_id).html();
            column_befor = $("#dis_weight").html();        //原权重值
            column  = $("#input-weight-"+column_id).val(); //现权重值
            now_input_type = $("#input-weight-" + column_id); //权重 ID
            now_edit_type  = $("#edit_weight-" + column_id);  //修改 按钮ID
        }
        if(edit_column == "修改"){
            //处理 同时存在多个input编辑问题
            $(".input_edit").attr("disabled", "disabled");
            $(".edit_sub").html("修改");

            now_input_type.removeAttr("disabled");
            now_edit_type.html("确认");
        }else{
            if(column_befor == column){
                now_input_type.attr("disabled", "disabled");
                now_edit_type.html("修改");
            }else {
                $.post("{:U('NewsSet/Edit')}", {type: type, id: column_id, val: column},
                    function (result) {
                        if (result == 1) {
                            now_input_type.attr("disabled", "disabled");
                            now_edit_type.html("修改");
                            location.reload();
                        }else{
                            alert("异常!");
                        }
                    }
                );
            }
        }
    };

    function edit_liverole(column_id,admin_ids,usernames,live_status){
        layer.open({
            type: 2,
            //skin: 'layui-layer-lan',
            title: '直播权限设置',
            fix: false,
            shadeClose: true,
            maxmin: true,
            area: ['700px', '300px'],
            content: "<?php echo U('Admin/NewsSet/editliverole')?>"+'&column_id='+column_id+'&admin_ids='+admin_ids+'&usernames='+usernames+'&live_status='+live_status+'&type='+0,
            end: function(){
                location.reload();
            }
        });
    }
</script>

</body>
</html>